import { Controller, Get, Post, UseInterceptors, UploadedFile, Req } from '@nestjs/common';
import { UploadService } from './upload.service';
import { FileInterceptor } from '@nestjs/platform-express';

@Controller('upload')
export class UploadController {
  constructor(private readonly uploadService: UploadService) {}

  @Post('img')
  @UseInterceptors(FileInterceptor('file'))
  upload(@UploadedFile() file,@Req() req) {
    const host=req.get('host');
    return {path:`http://${host}/assets/img/${file.filename}`}
  }
}
